/****************************************************************************
 * Copyright (C) 2012 Dj_Skual
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************/
#ifndef _MAINMENU_H
#define _MAINMENU_H

#include "../Settings/Menus/SettingsMenu.h"
#include "../Network/Updates/AutoUpdateCheckTask.h"
#include "Clock.h"

class MainMenu : public GuiFrame, public sigslot::has_slots<>
{
	public:
		static MainMenu *Instance() { if(!instance) instance = new MainMenu(); return instance; }
		static void DestroyInstance() { delete instance; instance = NULL; }
		
		void hide();
		void show();
		
		void ExecuteUpdate();
		
		std::string updateUrl;
		bool updateRequested;
		
	private:
		MainMenu();
		virtual ~MainMenu();
		
		void OnFadeEffectFinish(GuiElement *element);
		void OnManageButtonClick(GuiButton *sender, int pointer, const POINT &p);
		void OnSettingsButtonClick(GuiButton *sender, int pointer, const POINT &p);
		void OnHomebrewButtonClick(GuiButton *sender, int pointer, const POINT &p);
		void OnMusicButtonClick(GuiButton *sender, int pointer, const POINT &p);
		void OnDevicesStateChange(int device, bool inserted);
		void OnSdCardButtonClick(GuiButton *sender, int pointer, const POINT &p);
		void OnMenusClosing(GuiFrame *menu);
		void OnSettingsForcedClosing(SettingsMenu *menu);
		void OnUpdateCheckEnd(AutoUpdateCheckTask * task, std::string url);
		
		static MainMenu *instance;
		bool diplayed;
		
		Clock * clock;
		
		GuiImage *bgImg;
		GuiImageData *bgData;
		
		GuiImageData * SdCardImgData;
		GuiImageData * SdCardImgGrayData;
		
		GuiImage * SdCardImg;
		GuiImage * SdCardImgGray;
		
		GuiTooltip * ManageTT;
		GuiTooltip * SettingsTT;
		GuiTooltip * HomebrewTT;
		GuiTooltip * MusicPlayerTT;
		GuiTooltip * SdCardTT;
		
		PictureButton * ManageBtn;
		PictureButton * SettingsBtn;
		PictureButton * HomebrewBtn;
		PictureButton * MusicPlayerBtn;
		PictureButton * SdCardBtn;
		
		GuiSound * BtnSoundClick;
		GuiSound * BtnSoundOver;
		
		GuiTrigger * trigA;
};

#endif
